import java.util.HashMap;
import java.util.Map;


public class P26 {
	private static Map<String, Integer> map = new HashMap<String, Integer>();
	private static Map<String, Integer> positionMap = new HashMap<String, Integer>();
	
	private static String divide(int a, int b, String result) {
		String representedResult = checkRecurring(a, b, result);
		if (representedResult != null) {
			return representedResult;
		}
		
		if (a < b) {
			if (result.length() == 0) {
				return divide(10*a, b, "0.");
			} else {				
				return divide(10*a, b, result + "0");
			}
		} 
		
		if (a%b == 0) {
			return result += String.valueOf(a/b);
		} else {			
			return divide(10*(a%b), b, result + String.valueOf(a/b));
		}
	}

	private static String checkRecurring(int a, int b, String result) {
		String key = a + "," + b;
		Integer i = map.get(key);
		if (i != null) {
			return result.substring(0, positionMap.get(key)) + "(" + result.substring(positionMap.get(key)) + ")";
		} else {
			map.put(key, a/b);
			positionMap.put(key, result.length());
			return null;
		}
	}
	
	public static void main(String[] args) {
		int max = 0;
		String maxPart = "";
		for (int i = 2; i < 1000; i++) {
			String result = divide(1, i, "");
			//System.out.println(">>>" + i + ":" + result);
			int index1 = result.indexOf("(");
			if (index1 >= 0) {
				int index2 = result.indexOf(")");
				String part = result.substring(index1 + 1, index2);
				//System.out.println("part:" + part);
				int n = part.length();
				if (max < n) {
					System.out.println(i);
					System.out.println(n);
					System.out.println(result);					
					max = n;
					maxPart = part;
					System.out.println();
				}
			}	
			//System.out.println(i);
		}
		//System.out.println(maxPart);
	}
}
